{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  温高枫  \n",
    "+ 学号  0165202"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "等级从0到10\n",
      "贫困户\n",
      "需要帮扶\n",
      "\n",
      "贫困户\n",
      "需要帮扶\n",
      "\n",
      "非贫困户\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(\"等级从0到10\")\n",
    "class Poor():\n",
    "    def __init__(self,education,house,water,nutrition):\n",
    "        self.education=education\n",
    "        self.house=house\n",
    "        self.water=water\n",
    "        self.nutrition=nutrition\n",
    "    \n",
    "    def poorman(self):\n",
    "        x=0\n",
    "        if self.education<=5:\n",
    "            x=x+1\n",
    "        if self.house<=5:\n",
    "            x=x+1\n",
    "        if self.water<=5:\n",
    "            x=x+1\n",
    "        if self.nutrition<=5:\n",
    "            x=x+1\n",
    "        if x>2:\n",
    "            print(\"贫困户\")\n",
    "            print(\"需要帮扶\\n\")\n",
    "        else:\n",
    "            print(\"非贫困户\\n\")\n",
    "            \n",
    "a_1=Poor(1,3,4,5)\n",
    "a_1.poorman()\n",
    "\n",
    "a_2=Poor(1,7,4,5)\n",
    "a_2.poorman()\n",
    "\n",
    "a_3=Poor(1,6,4,7)\n",
    "a_3.poorman()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "体重正常\n",
      "\n",
      "BMI可能偏大\n",
      "\n",
      "BMI可能偏大\n",
      "\n"
     ]
    }
   ],
   "source": [
    "class student():\n",
    "    def __init__(self,name,grade,sleep):\n",
    "        self.name=name\n",
    "        self.grade=grade\n",
    "        self.sleep=sleep\n",
    "    \n",
    "    def fat(self,x1,x2): \n",
    "        if self.grade>x1 and self.sleep<x2:\n",
    "            print(\"BMI可能偏大\\n\")\n",
    "        else:\n",
    "            print(\"体重正常\\n\")\n",
    "            \n",
    "a=student('小明',90,6)\n",
    "a.fat(90,6)\n",
    "b=student('小红',95,5)\n",
    "b.fat(90,6)\n",
    "c=student('小兰',90,6)\n",
    "c.fat(85,7)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "体重正常\n",
      "\n",
      "体重正常\n",
      "\n",
      "BMI可能偏大\n",
      "趋向正常\n",
      "\n"
     ]
    }
   ],
   "source": [
    "class running(student):\n",
    "    def __init__(self,name,grade,sleep,time):\n",
    "        super().__init__(name,grade,sleep)\n",
    "        self.time=time\n",
    "    def run(self,x1,x2): \n",
    "        if self.grade>x1 and self.sleep<x2:\n",
    "            print(\"BMI可能偏大\")\n",
    "            if self.time>30:\n",
    "                print(\"趋向正常\\n\")\n",
    "        else:\n",
    "            print(\"体重正常\\n\")\n",
    "\n",
    "            \n",
    "runner=running('小明',90,6,32)\n",
    "runner.run(90,6)\n",
    "\n",
    "\n",
    "runner=running('小明',90,6,31)\n",
    "runner.run(90,6)\n",
    "\n",
    "runner=running('小明',90,6,31)\n",
    "runner.run(85,7)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
